pgsql.hackers
[Top] [All Lists]

[patch] GUC source file and line number

Subject: [patch] GUC source file and line number
From: Alvaro Herrera
Date: Thu, 28 Aug 2008 13:08:58 -0400
Newsgroups: pgsql.hackers
Hi,

Here's a patch to add source file and line numbers to GUC variables.
Basically this makes pg_settings look like this:

alvherre=# select name, setting, sourcefile, sourceline from pg_settings where 
name like '%work%';
          name          | setting |                 sourcefile                 
| sourceline 
------------------------+---------+--------------------------------------------+------------
 autovacuum_max_workers | 3       |                                            
|           
 maintenance_work_mem   | 32768   | /pgsql/install/00head/data/postgresql.conf 
|        119
 work_mem               | 2048    | /pgsql/install/00head/data/workmem.conf    
|          4
(3 lignes)

This should make life easier for tools trying to find the config file
each setting is from (and possibly edit it).

It was initially authored by Magnus, but I had to hit it with the clue
stick until it understood reset sources, i.e. to make it behave sanely
when a session has a SET value and then a SIGHUP causes the backend to
read a config file that has changed underneath it:

-- initial value was 1MB

alvherre=# select name, setting, sourcefile, sourceline from pg_settings where 
name = 'work_mem';
          name          | setting |                 sourcefile                 
| sourceline 
------------------------+---------+--------------------------------------------+------------
 work_mem               | 1024    | /pgsql/install/00head/data/workmem.conf    
|          1
(1 ligne)

alvherre=# set work_mem to 200;
SET
alvherre=# select name, setting, sourcefile, sourceline from pg_settings where 
name = 'work_mem';
          name          | setting |                 sourcefile                 
| sourceline 
------------------------+---------+--------------------------------------------+------------
 work_mem               | 200     |                                            
|           
(1 ligne)

-- SIGHUP happened here, file was changed to 2MB and the setting moved some 
lines below

alvherre=# select name, setting, sourcefile, sourceline from pg_settings where 
name = 'work_mem';
          name          | setting |                 sourcefile                 
| sourceline 
------------------------+---------+--------------------------------------------+------------
 work_mem               | 200     |                                            
|           
(1 ligne)

alvherre=# reset work_mem ;
RESET
alvherre=# select name, setting, sourcefile, sourceline from pg_settings where 
name = 'work_mem';
          name          | setting |                 sourcefile                 
| sourceline 
------------------------+---------+--------------------------------------------+------------
 work_mem               | 2048    | /pgsql/install/00head/data/workmem.conf    
|          4
(1 ligne)


-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment: guc-sourcefile.patch
Description: Text Data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@xxxxxxxxxxxxxx)
To make changes to your subscription:
                                www.postgresql.org/mailpref/pgsql-hackers">http://www.postgresql.org/mailpref/pgsql-hackers
<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy